Repository navigation
feat(broker): pure scope-decision core (Pillar 3 step 1) - #303
Merged
Merged
Conversation
The deterministic, zero-LLM floor for the exec-broker (design: kit-research/docs/research/pillar3-exec-broker-5.0.md §3.1). Adds src/broker/scope.ts — three pure predicates over a ProfileScope (Pillar 4's signed RoE), no I/O: - hostInScope: egress allowlist with exact + subdomain match; an exact entry always wins, but loopback/RFC1918/link-local hosts are never subdomain-matched (a broad entry can't be tricked into permitting an internal target). Undefined/empty egress => nothing reachable. - pathInScope: traversal-safe containment against fs write-scope (a '..' escape lands outside and is denied); undefined/empty fs defaults to the project root '.'. - secretInScope: secret-scoped by default — only declared keys; undefined/empty => none. - isLoopbackOrPrivate helper (exported) for the egress guard. Enforcement points (PreToolUse hooks, withGovernance) sit above this and feed the scope via verifiedScope() (fail-closed — a null scope never reaches here). 13 unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
✅ Docker image built successfully
|
This was referenced Jul 10, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
First build step of the Pillar 3 exec-broker (5.0-rc). The deterministic, zero-LLM floor: three pure predicates that answer "is this action inside the agent's SCOPE?" against a
ProfileScope(Pillar 4's signed RoE). No I/O, no CLI, no enforcement yet — those sit above this in later steps and feed the scope viaverifiedScope()(fail-closed).Type of Change
Related Issues
kit-research/docs/research/pillar3-exec-broker-5.0.md§3.1 (merged as kit-research chore: flush dead app-ops + SaaS-scaffold code (~21.6k lines) #30)verifiedScope()(feat(profile): signed scope/RoE + verifiedScope for Pillar 3 (Pillar 4 step 5) #298) as its scope source (in later steps).Changes Made
src/broker/scope.ts:hostInScope— egress allowlist with exact + subdomain match; an exact entry always wins, but loopback / RFC1918 / link-local hosts are never subdomain-matched (a broadexample.comentry can't be tricked into permitting an internal target). Undefined/empty egress ⇒ nothing reachable.pathInScope— traversal-safe containment against the fs write-scope (a..escape resolves outside and is denied); undefined/emptyfsdefaults to the project root..secretInScope— secret-scoped by default: only declared keys; undefined/empty ⇒ none.isLoopbackOrPrivate(exported) for the egress guard.src/broker/scope.test.ts— 13 tests (exact/subdomain/suffix-trick/empty egress; loopback never subdomain-matched but honored if exact; case + trailing-dot; fs default-root / traversal-escape / explicit sub-scope / root-itself; secret declared-only; RFC1918 boundary cases).Testing
Test Coverage
npm test) — full suite 2677 pass / 0 fail (2664 baseline + 13)Manual Testing
npx tsc --noEmit→ clean.npx eslint src→ 0 errors.npm run build && node scripts/test.mjs→ 2677 pass, 0 fail.npx prettier --check→ formatted.Breaking Changes
None / N/A — new module; nothing imports it yet.
Checklist
npm test)Performance Impact
Reviewer Notes
The security-relevant subtlety is in
hostInScope: subdomain matching is convenient but must never widen to internal targets, so loopback/private hosts are matchable only by a verbatim allowlist entry — a broad public entry can't be leveraged into SSRF against an internal host. Next steps: fail-closed scope source (brokerScope=verifiedScope→ scope|null) +kit doctorstatus, then the PreToolUse enforcer, then integration intowithGovernance.🤖 Generated with Claude Code
https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
Generated by Claude Code